<form action="<?php echo url_for('producto/list') ?>" method="get" class="yform columnar">

<fieldset>
<legend>Buscar:</legend>
    <div class="type-text">
        <label for="codigo">C&oacute;digo:</label>
        <?php echo input_tag('codigo') ?></div>

    <div class="type-text">
        <label for="precio">Precio:</label>
        <?php echo input_tag('precio') ?>
    </div>
    <div class="type-text">
        <label for="nombre">Nombre:</label>
        <?php echo input_tag('nombre') ?>
    </div>

    <div class="type-button">
    <?echo submit_tag('Buscar') ?> <?echo button_to('Ver todos', 'producto/list') ?>
    </div>
</fieldset>
</form>
<table class="full">
    <thead>
        <th><a href="<?echo ($sf_request->getParameter('type') == 'asc')?url_for('producto/list?order=codigo&type=desc'): url_for('producto/list?order=codigo&type=asc')?>">C&oacute;digo</a></th>
        <th>Nombre</th>
        <th>Descripcion</th>
        <th><a href="<?echo ($sf_request->getParameter('type') == 'desc')?url_for('producto/list?order=precio&type=asc'): url_for('producto/list?order=precio&type=desc')?>">Precio</a></th>
        <th><a href="<?echo ($sf_request->getParameter('type') == 'asc')?url_for('producto/list?order=codigo&type=desc'): url_for('producto/list?order=stock&type=asc')?>">Stock disponible</a></th>
    </thead>
    <tbody>
<?php foreach ($pager->getResults() as $p): ?>
        <tr>
            <td><?=$p->getCodigo() ?></td>
            <td><?=$p->getNombre() ?></td>
            <td><?=$p->getDescripcion() ?></td>
            <td>$<?=$p->getPrecio() ?></td>
            <td <?php if ($p->getStockDisponible() > 0) print "style='color: green'"; else print "style='color: red'"; ?>><?=$p->getStockDisponible() ?></td>
        </tr>

<?php endforeach ?>
    </tbody>

</table>
<?php if ($pager->haveToPaginate()): ?>
<p>
<div>
<?php echo link_to('&nbsp;', "producto/list?page=".$pager->getFirstPage(), array('class' => 'pager_first')) ?>
                                                        <?php echo link_to('&nbsp;', "producto/list?page=".$pager->getPreviousPage(), array('class' => 'pager_prev')) ?>
                                                        <?php $links = $pager->getLinks(); foreach ($links as $page): ?>
                                                <?php echo ($page == $pager->getPage()) ? $page : link_to($page, "producto/list?page=".$page) ?>
                                                <?php if ($page != $pager->getCurrentMaxLink()): ?> - <?php endif ?>
                                                  <?php endforeach ?>
                                                        <?php echo link_to('&nbsp;', "producto/list?page=".$pager->getNextPage(), array('class' => 'pager_next')) ?>
                                                        <?php echo link_to('&nbsp;', "productoe/list?page=".$pager->getLastPage(), array('class' => 'pager_last')) ?>
</div>
</p>
<?php endif; ?>
